package com.tpyule.tpclass.service.impl;

import com.tpyule.tpclass.dao.RecordDao;
import com.tpyule.tpclass.entity.pojo.Record;
import com.tpyule.tpclass.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * @author zzz
 * @version 1.0
 * @date 2020/4/7 22:34
 */
@Service
public class RecordServiceImpl implements RecordService {
    @Autowired
    RecordDao recordDao;
    @Override
    public List<Record> listRecordByUserId(String userId) {
        if(userId==null){
            return null;
        }else {
            return recordDao.listRecordByUserId(userId);
        }
    }

    @Override
    public String addRecord(Record record) {
        record.setRecordId(UUID.randomUUID().toString().toUpperCase());
        int result = recordDao.addRecord(record);

        if(result>0){

            return record.getRecordId();
        } else {
            return null;
        }
    }
}
